import 'package:flutter/material.dart';
import 'dart:convert';
import '../model/goodDetail.dart';
import '../service/service_methods.dart';

class DetaiInfoProvider with ChangeNotifier {
  DetailsModel _goodsInfo;
  bool _isLeft = true;

  DetailsModel get goodsInfo => _goodsInfo;
  bool get isLeft => _isLeft;

  // 获取后台商品信息
  getGoodsInfo(String id) async {
    var formData = { 'goodId': id };

    await request('getGoodDetailById', formData: formData).then((val) {
      DetailsModel data = DetailsModel.fromJson(json.decode(val.toString()));
      _goodsInfo = data;
      notifyListeners();
    });
  }

  // 修改选中的状态
  changeActive(bool flag) {
    _isLeft = flag;
    notifyListeners();
  }
}